function filteredsignal = meanfilt1(signal, filterlength)
dx = (filterlength - 1)/2;
filteredsignal = signal;
for k = 1:length(signal)
    filteredsignal(k) = mean(signal(max(k-dx,1):min(k+dx,length(signal))));
end
end